package com.taobao.api.request;

import java.util.Map;

import com.taobao.api.ApiRuleException;
import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.RequestCheckUtils;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.TradeGetResponse;

/**
 * TOP API: taobao.trade.get request
 * 
 * @author auto create
 * @since 1.0, 2013-07-21 16:38:14
 */
public class TradeGetRequest implements TaobaoRequest<TradeGetResponse> {

  private Map<String, String> headerMap = new TaobaoHashMap();
  private TaobaoHashMap       udfParams;                      // add
                                                              // user-defined
                                                              // text parameters
  private Long                timestamp;

  /**
   * 需要返回的字段。目前支持有：<br>
   * 
   * 1. Trade中可以指定返回的fields:seller_nick, buyer_nick, title, type, created, tid,
   * seller_rate, buyer_rate, status, payment, discount_fee, adjust_fee,
   * post_fee, total_fee, pay_time, end_time, modified, consign_time,
   * buyer_obtain_point_fee, point_fee, real_point_fee, received_payment,
   * commission_fee, buyer_memo, seller_memo, alipay_no, buyer_message,
   * pic_path, num_iid, num, price, cod_fee, cod_status, shipping_type，
   * is_daixiao <br>
   * 2. Order中可以指定返回fields:orders.title, orders.pic_path, orders.price,
   * orders.num, orders.num_iid, orders.sku_id, orders.refund_status,
   * orders.status, orders.oid, orders.total_fee, orders.payment,
   * orders.discount_fee, orders.adjust_fee, orders.sku_properties_name,
   * orders.item_meal_name, orders.outer_sku_id, orders.outer_iid,
   * orders.buyer_rate, orders.seller_rate， orders.is_daixiao <br>
   * 3. fields：orders（返回Order中的所有允许返回的字段）
   */
  private String              fields;

  /**
   * 交易编号
   */
  private Long                tid;

  public void setFields(String fields) {
    this.fields = fields;
  }

  public String getFields() {
    return this.fields;
  }

  public void setTid(Long tid) {
    this.tid = tid;
  }

  public Long getTid() {
    return this.tid;
  }

  public Long getTimestamp() {
    return this.timestamp;
  }

  public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
  }

  public String getApiMethodName() {
    return "taobao.trade.get";
  }

  public Map<String, String> getTextParams() {
    TaobaoHashMap txtParams = new TaobaoHashMap();
    txtParams.put("fields", this.fields);
    txtParams.put("tid", this.tid);
    if (this.udfParams != null) {
      txtParams.putAll(this.udfParams);
    }
    return txtParams;
  }

  public void putOtherTextParam(String key, String value) {
    if (this.udfParams == null) {
      this.udfParams = new TaobaoHashMap();
    }
    this.udfParams.put(key, value);
  }

  public Class<TradeGetResponse> getResponseClass() {
    return TradeGetResponse.class;
  }

  public void check() throws ApiRuleException {
    RequestCheckUtils.checkNotEmpty(fields, "fields");
    RequestCheckUtils.checkNotEmpty(tid, "tid");
  }

  public Map<String, String> getHeaderMap() {
    return headerMap;
  }
}
